package com.taplinker.client.db.bean;

import android.content.ContentValues;

public class Customer {
	public final static String CUSTOMER_ID = "customerId";
	public final static String CUSTOMER_NAME = "customerName";
	public final static String VISITOR_ID = "visitorId";
	
	private int customerId;
	private String customerName;
	private String visitorId;
	
	public int getCustomerId() {
		return customerId;
	}
	public void setCustomerId(int customerId) {
		this.customerId = customerId;
	}
	public String getCustomerName() {
		return customerName;
	}
	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}
	public String getVisitorId() {
		return visitorId;
	}
	public void setVisitorId(String visitorId) {
		this.visitorId = visitorId;
	}
	
	public ContentValues convert2ContentValues() {
		ContentValues cv = new ContentValues();
		cv.put(CUSTOMER_ID, customerId);
		cv.put(CUSTOMER_NAME, customerName);
		cv.put(VISITOR_ID, visitorId);
		return cv;
	}
	
	public static ContentValues convert2ContentValues(Customer customer) {
		ContentValues cv = null;
		if(customer != null) {
			cv = new ContentValues();
			cv.put(CUSTOMER_ID, customer.getCustomerId());
			cv.put(CUSTOMER_NAME, customer.getCustomerName());
			cv.put(VISITOR_ID, customer.getVisitorId());
		}
		return cv;
	}
	
	public static Customer buildFromContentValues(ContentValues cv) {
		Customer customer = null;
		if(cv != null) {
			customer = new Customer();
			customer.setCustomerId(cv.getAsInteger(CUSTOMER_ID));
			customer.setCustomerName(cv.getAsString(CUSTOMER_NAME));
			customer.setVisitorId(cv.getAsString(VISITOR_ID));
		}
		return customer;
	}
}
